package Hxw3DEngine.core.display 
{
	import Hxw3DEngine.core.materials.ColorMaterial;
	import Hxw3DEngine.core.materials.shader.filters.BillboardFilter;
	import Hxw3DEngine.utils.Color;
	import Hxw3DEngine.core.component.renderer.MeshRenderer;
	import Hxw3DEngine.core.Resource.geometry.ResourceGeometry;
	import Hxw3DEngine.asset.parsers.bson.vo.Stream;
	/**
	 * ...
	 * @author ...
	 */
	public class Cube3D extends GameObject 
	{
	
		//暂时用来测试colorMat
		public function Cube3D(color:Color) 
		{
			
			var vertexData:Vector.<Number> = new <Number>[
				-1, 1, -1,
				1, 1, -1,
				1, 1, 1,
				-1, 1, 1,
				-1, -1, -1,
				1, -1, -1,
				1, -1, 1,
				-1, -1, 1
			];
		
			var indexData:Vector.<uint> = new <uint>[
				0, 1, 2, 2, 3, 0,
				6, 5, 4, 4, 7, 6,
				2, 6, 7, 7, 3, 2,
				4, 5, 1, 1, 0, 4,
				4, 0, 3, 3, 7, 4,
				2, 1, 5, 5, 6, 2
			];
			
			var mesh:MeshRenderer = new MeshRenderer;
			addComponent(mesh);
			mesh.geometry = new ResourceGeometry;
			mesh.geometry.createFromStreams(indexData, 8,[Stream.fromVector(Stream.stream_positions, vertexData)]);
			mesh.material = new ColorMaterial(color);
			mesh.material.shader.addFilter(new BillboardFilter());
		}
		
	}

}